#ifndef MODELHELPER_H
#define MODELHELPER_H

#include <QModelIndex>

class QAbstractItemModel;
class QAbstractItemView;
class QStandardItem;
class QTableView;
typedef QList<QModelIndex> QModelIndexList;

namespace ModelHelper
{
    bool isOnlyOneRowSelected (const QAbstractItemView* view);
    bool isCurrentIndexSelected (const QAbstractItemView* view);
    QModelIndexList allIndexes (const QTableView* view);
    QModelIndexList visibleIndexes (const QTableView* view);
    QModelIndexList selectedIndexes (const QAbstractItemView* view);
    QModelIndexList selectedVisibleIndexes (const QTableView* view);
    int rowsInSelection (const QAbstractItemView* view);
    QAbstractItemModel* normalModel (QAbstractItemModel* model);
    const QAbstractItemModel* normalModel (const QAbstractItemModel* model);
    QModelIndex normalIndex (const QModelIndex& modelIndex);
    QModelIndexList normalIndexes (const QModelIndexList& indexes, bool sort = true);
    int normalSelectedRow (const QAbstractItemView* itemView, int column = 0);
    QList<int> normalSelectedRows (const QAbstractItemView* view, int column = 0, bool sort = true);
    QAbstractItemModel* findHierarchicalHeaderModel (const QAbstractItemModel* model, const Qt::Orientation orientation);
    void setHierarchicalHeaderModel (QAbstractItemModel* model, const QAbstractItemModel* headerModel,
                                     const Qt::Orientation orientation);
    void setLeafCount (const QModelIndex& index, QAbstractItemModel* model);
    void setLeafCount (QStandardItem* item);
    void setVisibleLeafCount (QAbstractItemModel* headerModel, const QTableView* tableView,
                              const QModelIndex& item = QModelIndex(), int section = -1);
    int bottomSectionCount (const QAbstractItemModel* headerModel);
    int bottomVisibleSectionCount (const QAbstractItemModel* headerModel);

    void printModelContent (const QAbstractItemModel* model);
}

#endif // MODELHELPER_H
